package com.iotechn.unimall.app.api.shopMoney;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.iotechn.unimall.core.exception.ServiceException;
import com.iotechn.unimall.data.domain.ShopMoneyDO;
import com.iotechn.unimall.data.mapper.ShopMoneyMapper;
import com.iotechn.unimall.data.model.Page;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;


@Service
public class ShopMoneyServiceImpl implements ShopMoneyService {
    @Autowired
    private ShopMoneyMapper shopMoneyMapper;

    @Override
    public Page<ShopMoneyDO> list(Integer page, Integer limit, Long articleTypeId) throws ServiceException {
        Wrapper<ShopMoneyDO> wrapper = new EntityWrapper<ShopMoneyDO>();

        wrapper.orderBy("id", false);
        Integer count = shopMoneyMapper.selectCount(wrapper);
        List<ShopMoneyDO> ShopMoneyDOS = shopMoneyMapper.selectPage(new RowBounds((page - 1) * limit, limit), wrapper);
        return new Page<>(ShopMoneyDOS, page, limit, count);
    }

    @Override
    public ShopMoneyDO detail(Long id) throws ServiceException {
        return shopMoneyMapper.selectById(id);
    }

}